package edu.bupt.hbase;

import java.util.Arrays;
import java.util.Scanner;
import java.util.Stack;

public class ForTheTest {
    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        String nStr = scanner.next();
        int n = Integer.parseInt(nStr);

        long[] hights = new long[n];
        String hightStr = scanner.next();
        String[] s1 = hightStr.split(" ");
        for (int i=0;i<n;i++){
            hights[i] = Long.parseLong(s1[i]);
        }



        Stack<Long> longStack = new Stack<Long>();

        int segs = 0;

        longStack.push(hights[0]);

        for (int i=0;i<n;i++){
            boolean flag = false;

            while(!longStack.empty() && longStack.peek()>hights[i]){
                longStack.pop();
                flag = true;
            }

            if (flag){
                segs ++;
            }

        }


    }
}
